<%@page import="tools.MyTool"%>
<%@page import="java.util.Iterator"%>
<%@page import="accessor.HomeProductAccessor"%>
<%@page import="accessor.Products"%>
<%@include file="no_banner_header.jsp" %>

<%
    int productID = request.getParameter("productID") != null ? Integer.parseInt(request.getParameter("productID")) : 0;

    Products detail = new HomeProductAccessor().getProductDetails(productID);
    detail.getPrice();
%>
<script type="text/javascript">
    $(document).ready(function(){
        $("a#add_to_cart").click(function(){
            var quantity = $("#product_quantity").val();
            $.ajax({
                type: 'POST',
                url: '../do_add_cart',
                data: {
                    'productID' : "<%=detail.getProductID()%>",
                    'productName' : "<%=detail.getProductName()%>",
                    'defaultImage' : "<%=detail.getDefaultImage()%>",
                    'quantity' : quantity,
                    'price' : "<%=detail.getPrice()%>"
                },
                dataType:"json",
                success: function(data)                          
                {     
                    $('#cart_count').html(data);                            
                    alert('You have put into your cart '+quantity+' product');
                }
            });  
            return false;
        });
    });  
</script>
<div class="content_bar"><%=detail.getProductName()%></div>
<div class="break_line"></div>
<div class="break_line"></div>
<div id="wrapper_detail_product">
    <div id="wrapper_detail_left">
        <a href="#"><img src="../assets/img/p/<%=detail.getDefaultImage()%>" width="450" height="350" style="border: 0px solid #DDDDDD;" /></a>
    </div>
    <!-----------END wrapper_detail_left-------------->	
    <div id="wrapper_detail_bottom">
        <div id="detail_right">
            <div id="description_detail">
                <p>
                    <span style="color:#0c7007">Description: </span>
                    <%=detail.getDescription()%>
                </p>
            </div>
            <!-----------END description_detail-------------->
            <div id="add_cart_detail" align="center">
                <table width="50%">
                    <tr>
                        <td valign="bottom">
                            <p style="color:#FF6400">PRICE: <span class="orange" style="font-size:18px">$411</span>
                                <br/>
                                <br/>
                                UNIT IN STOCK : <%=detail.getQuantity() > 0 ? "AVAILABLE" : "OUT OF STOCK"%>
                                <br/>
                            <div class="product_label">
                                <span class="product_info_left">Quantity :</span>
                                <input id="product_quantity" size="12" name="" type="text" value="1"/>
                                <input type="hidden" id="quantity_in_stock" value="<%=detail.getQuantity()%>"/>
                            </div>
                        </td>
                        <td width="178px" align="center" valign="bottom">
                            <a href="#" id="add_to_cart"><img src="../assets/css/frontend/images/add_cart.png" alt="" style="border: none;"/></a>
                            <div style="color:#0c7007"><p>ORDER THIS PRODUCT</p></div>
                        </td>
                    </tr>
                </table>
            </div>
            <!-----------END add_cart_detail-------------->	
        </div>
        <!-----------END detail_right-------------->
    </div>
    <!-----------END wrapper_detail_right-------------->	
</div>
<div class="break_line"></div>                                        

<div style="clear: both;">&nbsp;</div>
<%@include file="footer.jsp" %>